package com.c2.service.impl;

import com.c2.entity.EbProduct;
import com.c2.mapper.ProductMapper;
import com.c2.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Stars Lee
 * @date 2020/9/16 - 15:16
 */
@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductMapper productMapper;

    @Override
    public List<EbProduct> listByPage(Integer page,Integer pageSize){
        int from=(page-1)*pageSize;
        return productMapper.findByPage(from,pageSize);
    }

    @Override
    public List<EbProduct> likeByPage(String epName,Integer likePage,Integer likePageSize){
        return productMapper.findByLikeName(epName,(likePage-1)*likePageSize,likePageSize);
    }

    @Override
    public Integer findLikeMaxPage(String epName,Integer likePageSize){
        return productMapper.likeMaxPage(epName,likePageSize);
    }

    @Override
    public Integer findMaxPage(Integer pageSize){
        return productMapper.findAllPage(pageSize);
    }

    @Override
    public Integer toSaveProduct(EbProduct ebProduct){

        return productMapper.insertSave(ebProduct);
    }

    @Override
    public Integer toDeleteProduct(Integer ebId){
        return productMapper.deleteByPrimary(ebId);
    }

    @Override
    public List<EbProduct> selectByCondition(Integer epId){
        return productMapper.findByPrimary(epId);
    }
    @Override
    public Integer toUpdateById(EbProduct ebProduct){
        return productMapper.updateByPrimary(ebProduct);
    }
}
